<template>
  <view class="top-panel-container" :style="{ paddingTop: $safeArea?.top + 'px' }">
    <view class="avatar-name">
      <view class="avatar">
        <image :src="info?.head_img_" mode="aspectFill" />
      </view>
      <view class="">
        <view class="name"> {{ info?.client_name_ }}</view>
        <view class="real-tag no-real-name" v-if="info?.create_step_ == 100">未实名</view>
        <view class="real-tag real-name" v-else>已实名</view>
      </view>
    </view>
    <view class="statistics">
      <navigator url="/pages/order/list" open-type="switchTab" hover-class="navigator-hover" class="navigator">
        <text class="number">{{ info?.wait_pay_.toFixed(2) }}</text>
        <text>待付款</text>
      </navigator>
      <navigator url="/pages/" open-type="navigate" hover-class="navigator-hover" class="navigator">
        <text class="number">{{ info?.wait_pay_.toFixed(2) }}</text>
        <text>余额</text>
      </navigator>
    </view>
  </view>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";

import Apis from "@/services/modules/account"
import type { AccountInfoData } from "@/types/account";

import { useMemberStore } from "@/stores";

const { profile } = useMemberStore()

onMounted(() => {
  getAcountInfoData()

})

const info = ref<AccountInfoData>()
const getAcountInfoData = async () => {
  const { data } = await Apis.getAccountInfoApi()
  info.value = data
  getCapitalAccountData(data.client_id_)
}
const getCapitalAccountData = async (id_: number) => {
  console.log(profile)
  const { data } = await Apis.getCapitalAccountApi(`${id_}`)
  // info.value = data
}

</script>

<style lang="scss" scoped>
.top-panel-container {
  position: relative;
  height: 38vh;
  background: linear-gradient(180deg, #FFE6A9 0%, #FFF3EB 100%);

  .avatar-name {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 20px 40px;
    color: #fff;

    .avatar {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      overflow: hidden;
      margin-right: 16px;
    }

    .name {
      font-weight: 600;
      font-size: 16px;
      color: #000000;
      line-height: 22px;
    }

    .real-tag {
      background: #FFDE87;
      border-radius: 4px;
      font-size: 12px;
      padding: 2px 4px;
      color: #999;
      margin-top: 6px;
    }

    .no-real-name {
      color: #999;
    }

    .real-name {
      font-weight: 400;
      color: #AF6D0B;
    }
  }

  .statistics {
    display: flex;
    justify-content: space-around;
    color: #452600;
    font-family: PingFangSC, PingFang SC;
    background: linear-gradient(134deg, #FFC24E 0%, #FFDA7A 100%);
    border-radius: 8px;

    width: calc(100% - 24px);
    margin: auto;
    padding: 16px 0;

    .navigator {
      display: flex;
      flex-direction: column;
      justify-content: center;
      width: 100%;

      text {
        width: 100%;
        display: flex;
        padding: 2px 0;
        font-size: 16px;
        justify-content: center;
        font-weight: 400;
        font-size: 14px;
        color: #713E00;
      }

      .number {
        font-weight: 600;
        font-size: 20px;
        color: #452600;
        line-height: 28px;
      }
    }
  }
}
</style>
